package com.woniuxy.controller;

import com.woniuxy.publisher.CodePublisher;
import com.woniuxy.util.ConstantUtil;
import com.woniuxy.util.ResponseEnum;
import com.woniuxy.util.ResponseUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 验证码控制器类
 * 提供发送验证码等操作接口
 */
@RestController
@RequestMapping("/code")
public class CodeController {
    @Resource
    private CodePublisher codePublisher;

    /**
     * 发送验证码
     * @param phoneNum 手机号码
     * @return 返回发送验证码的响应结果
     */
    @PostMapping("/sendCode/{phoneNum}")
    public ResponseUtil sendCode(@PathVariable("phoneNum") String phoneNum){
        codePublisher.sendCode(phoneNum);
        return ResponseUtil.get(ResponseEnum.CODE_SEND_OK);
    }
}
